Skip to content

Migrate snapping from OL2 to OL10#6828

Open
meyerlor wants to merge 1 commit into
3liz:masterfrom
meyerlor:ol10-snapping
Open

Migrate snapping from OL2 to OL10#6828
meyerlor wants to merge 1 commit into
3liz:masterfrom
meyerlor:ol10-snapping

Conversation

@meyerlor
Copy link
Copy Markdown
Collaborator

@meyerlor meyerlor commented May 14, 2026

Picking up the work of my previous attempt to migrate the edition tools to OL10 - i tried to atomize the needed changes as much as possible to make reviewing easier. This is the first of 3 PR's in the initial pipeline, targeting only the snapping function. Opening those other two PR's as draft, they are based on this PR subsequently.
This PR's scope:

  • Replace OpenLayers.Control.Snapping with the OL10 Snap interaction.
  • Render snap features as a solid orange overlay while snapping is active.
  • Drop the manual refresh button: getSnappingData() now runs automatically on moveend and on layer-tree visibility changes (the snapLayersRefreshable state and snapping.refreshable event are gone, no consumers remained).
  • OL10 Snap exposes a single vertex flag and a single pixelTolerance, so snap_vertices is OR-ed with snap_intersections and pixelTolerance is max(snap_vertices_tolerance, snap_segments_tolerance). Worth flagging for projects that configure vertex vs intersection independently.
  • Public reorderSnapInteraction() lets future callers re-add the Snap interaction so OL processes it before any recently-added Draw / Modify / Translate. No-op when snap is inactive.

Tests:

  • snap.spec.js: remove three WFS 1.1.0 / SRSNAME / datum-shift tests that exercised the OL2 snap WFS path (replaced by OL10 GeoJSON parsing). Strip refresh-button click / disabled-state assertions from the snap panel test now that refresh is automatic.

This PR ships the snap infrastructure but does not visibly engage with the OL2 edition Draw / Modify yet. Snapping starts to actually snap once the follow-up OL10 edition migration lands.

Note: The provided gif shows the snapping function is working on my testsystem where the follow up PR's are merged already:
Snapping

* Replace OpenLayers.Control.Snapping with the OL10 Snap interaction.
* Render snap features as a solid orange overlay while snapping is active.
* Drop the manual refresh button: getSnappingData() now runs automatically
  on moveend and on layer-tree visibility changes (the
  snapLayersRefreshable state and snapping.refreshable event are gone,
  no consumers remained).
* OL10 Snap exposes a single vertex flag and a single pixelTolerance, so
  snap_vertices is OR-ed with snap_intersections and pixelTolerance is
  max(snap_vertices_tolerance, snap_segments_tolerance). Worth flagging
  for projects that configure vertex vs intersection independently.
* Public reorderSnapInteraction() lets future callers re-add the Snap
  interaction so OL processes it before any recently-added Draw / Modify
  / Translate. No-op when snap is inactive.

Tests:
* snap.spec.js: remove three WFS 1.1.0 / SRSNAME / datum-shift tests that
  exercised the OL2 snap WFS path (replaced by OL10 GeoJSON parsing).
  Strip refresh-button click / disabled-state assertions from the snap
  panel test now that refresh is automatic.

This PR ships the snap infrastructure but does not visibly engage with
the OL2 edition Draw / Modify yet. Snapping starts to actually snap once
the follow-up OL10 edition migration lands.
@github-actions github-actions Bot added this to the 3.11.0 milestone May 14, 2026
@meyerlor meyerlor requested a review from nboisteault May 14, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

draw Drawing tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant